# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=yasm
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.3.0
pkgrel=6
pkgdesc="A rewrite of NASM to allow for multiple syntax supported (NASM, TASM, GAS, etc.) (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
license=('BSD' 'GPL2' 'LGPL2.1' 'PerlArtistic')
url="https://www.tortall.net/projects/yasm/"
msys2_references=(
  "cpe: cpe:/a:tortall:yasm"
  "cpe: cpe:/a:yasm_project:yasm"
)
depends=("${MINGW_PACKAGE_PREFIX}-gettext-runtime")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-gettext-tools"
             "${MINGW_PACKAGE_PREFIX}-python3")
source=(https://www.tortall.net/projects/yasm/releases/${_realname}-${pkgver}.tar.gz)
sha256sums=('3dce6601b495f5b3d45b59f7d2492a340ee7e84b5beca17e48f862502bd5603f')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
}

build() {
  mkdir -p "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST}

  make
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}
  make DESTDIR="${pkgdir}" install
  install -Dm644 "${srcdir}"/${_realname}-${pkgver}/COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
  install -Dm644 "${srcdir}"/${_realname}-${pkgver}/BSD.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/BSD.txt"
}
